package vn.bang.utility;

public final class LongUtil {

	/**
	 * @param numberString
	 *            the string to be parsed.
	 * @return an Long object holding the value represented by the string
	 *         argument if the string cannot be parsed as an long; Otherwise,
	 *         return null.
	 */
	static public Long valueOf(String numberString) {
		Long longNumber = null;
		if (null != numberString) {
			try {
				longNumber = Long.valueOf(numberString);
			} catch (NumberFormatException numberFormatException) {
				longNumber = null; // Default if can't parse to Long.
			}
		}
		return longNumber;
	}

	/**
	 * @param numberString
	 *            a String containing the long representation to be parsed.
	 * @return The long value represented by the argument in decimal if the
	 *         string contain a parsable long; Otherwise, return null.
	 */
	static public long parseLong(String numberString) {
		long longNumber = 0;
		if (null != numberString) {
			try {
				longNumber = Long.parseLong(numberString);
			} catch (NumberFormatException numberFormatException) {
				longNumber = 0; // Default if can't parse to long.
			}
		}
		return longNumber;
	}

	/**
	 * Prevent constructor.
	 */
	private LongUtil() {
	}

}
